import { lazy } from 'react'
import { IRouteProps } from './routertypes'
import Login from '../views/login/login'
import HomeMain from '../views/home/main'
import HomeIndex from '../views/home/index'
// import Reminder from '../views/home/reminder'
// import Activity from '../views/home/activity'
// import TodayTask from '../views/home/todaotask'
// import CapitalFlow from '../views/home/capitalflow/capital-flow'
// import CapitalType from '../views/home/capitalflow/capital-type'
// import MemorandumList from '../views/home/memorandum/memorandum-list'
// import MemorandumDetail from '../views/home/memorandum/memorandum-detail'
// import CreateMemorandum from '../views/home/memorandum/create-memorandum'
// import ProfileIndex from '../views/home/profile/index'
// import NoMatchPage from '../views/404/404'

// 路由懒加载
const Reminder = lazy(() => import('../views/home/reminder'))
const Activity = lazy(() => import('../views/home/activity'))
const TodayTask = lazy(() => import('../views/home/todaotask'))
const CapitalFlow = lazy(() => import('../views/home/capitalflow/capital-flow'))
const CapitalType = lazy(() => import('../views/home/capitalflow/capital-type'))
const MemorandumList = lazy(
  () => import('../views/home/memorandum/memorandum-list'),
)
const MemorandumDetail = lazy(
  () => import('../views/home/memorandum/memorandum-detail'),
)
const CreateMemorandum = lazy(
  () => import('../views/home/memorandum/create-memorandum'),
)
const ProfileIndex = lazy(() => import('../views/home/profile/index'))
const NoMatchPage = lazy(() => import('../views/404/404'))

const routesMap: IRouteProps[] = [
  {
    path: '/login',
    excat: true,
    component: Login,
    meta: {
      title: '登录',
      requiresAuth: false,
    },
  },
  {
    path: '/home',
    component: HomeMain,
    meta: {
      requiresAuth: true,
    },
    childrenRoutes: [
      {
        path: '/home/index',
        component: HomeIndex,
        exact: true,
        meta: {
          title: '后台首页',
          requiresAuth: true,
        },
      },
      {
        path: '/home/reminder',
        component: Reminder,
        exact: true,
        meta: {
          title: '提醒事项',
          requiresAuth: true,
        },
      },
      {
        path: '/home/activityList',
        component: Activity,
        exact: true,
        meta: {
          title: '活动清单',
          requiresAuth: true,
        },
      },
      {
        path: '/home/todayTask',
        component: TodayTask,
        exact: true,
        meta: {
          title: '今日待办',
          requiresAuth: true,
        },
      },
      {
        path: '/home/capitalFlow',
        component: CapitalFlow,
        exact: true,
        meta: {
          title: '资金流动',
          requiresAuth: true,
        },
      },
      {
        path: '/home/capitalFlow/type',
        component: CapitalType,
        exact: true,
        meta: {
          title: '创建类别',
          requiresAuth: true,
        },
      },
      {
        path: '/home/memorandum',
        component: MemorandumList,
        exact: true,
        meta: {
          title: '备忘录列表',
          requiresAuth: true,
        },
      },
      {
        path: ['/home/memorandum/create', '/home/memorandum/update/:id'],
        component: CreateMemorandum,
        exact: true,
        meta: {
          title: '备忘录创建',
          requiresAuth: true,
        },
      },
      {
        path: '/home/memorandum/detail/:id',
        component: MemorandumDetail,
        exact: true,
        meta: {
          title: '备忘录详情',
          requiresAuth: true,
        },
      },
      {
        path: '/home/setting',
        component: ProfileIndex,
        // 这里不能加exact:true
        meta: {
          title: '个人中心',
          requiresAuth: true,
        },
      },
      {
        path: '*',
        component: NoMatchPage,
        // 这里不能加exact:true
        meta: {
          title: '404 Not Found',
          requiresAuth: true,
        },
      },
    ],
  },
  {
    path: '*',
    component: NoMatchPage,
    // 这里不能加exact:true
    meta: {
      title: '404 Not Found',
      requiresAuth: false,
    },
  },
]

const Base = lazy(() => import('../views/home/profile/base'))
const InnerMessage = lazy(() => import('../views/home/profile/message'))
const NotificationPage = lazy(
  () => import('../views/home/profile/notification'),
)
const AccountPage = lazy(() => import('../views/home/profile/account'))
export const settingRoutes: IRouteProps[] = [
  {
    path: '/home/setting/base',
    component: Base,
    exact: true,
    meta: {
      title: '个人中心',
      requiresAuth: true,
    },
  },
  {
    path: '/home/setting/innerMessage',
    component: InnerMessage,
    exact: true,
    meta: {
      title: '消息中心',
      requiresAuth: true,
    },
  },
  {
    path: '/home/setting/notification',
    component: NotificationPage,
    exact: true,
    meta: {
      title: '消息通知',
      requiresAuth: true,
    },
  },
  {
    path: '/home/setting/account',
    component: AccountPage,
    exact: true,
    meta: {
      title: '账号设置',
      requiresAuth: true,
    },
  },
  {
    path: '*',
    component: NoMatchPage,
    // 这里不能加exact:true
    meta: {
      title: '404 Not Found',
      requiresAuth: true,
    },
  },
]

export default routesMap
